//
//  WDWD.m
//  EJLX
//
//  Created by xufei on 15/12/2.
//  Copyright © 2015年 江苏一键联信息科技有限公司. All rights reserved.
//

#import "WDWD.h"
#import "SecondWDWD.h"
//#import "ThireWDWD.h"
//#import "FourWDWD.h"
@implementation WDWD
+(id)userWithDictionary:(NSDictionary*)userDic
{
    return [[self alloc]initWithDictionary:userDic];
}
-(id)initWithDictionary:(NSDictionary*)userDic
{
    self=[super init];
    if (self)
    {
        
        _totalPage=[userDic[@"totalPage"]intValue];
         _page=[userDic[@"page"]intValue];
         _pageSize=[userDic[@"pageSize"]intValue];
         _shopId=[userDic[@"shopId"]intValue];
        _avatar=[userDic[@"avatar"]copy];
        _url=[userDic[@"url"]copy];
       
         _brand=[userDic[@"brand"]copy];
        if ([userDic[@"shopName"] isEqual:[NSNull null]])
        {
           _shopName=@"";
            
            
        }else{
           _shopName=[userDic[@"shopName"]copy];
            
            
        }

//        if ([userDic[@"shopName"]length])
//        {
//             _shopName=[userDic[@"shopName"]copy];
//        }
//        else
//        {
//            _shopName=@"";
//        }
        if ([userDic[@"phone"] isEqual:[NSNull null]])
        {
             _phone=@"";
            
            
        }else{
             _phone=[userDic[@"phone"]copy];
            
            
        }

//        if ([userDic[@"phone"]length])
//        {
//            _phone=[userDic[@"phone"]copy];
//        }
//        else
//        {
//            _phone=@"";
//        }
        
        NSMutableArray*latest1=userDic[@"latest1"];
         NSMutableArray*latest7=userDic[@"latest7"];
        NSMutableArray*previous=userDic[@"previous"];
        _latest1=[NSMutableArray array];
        _latest7=[NSMutableArray array];
        _previous=[NSMutableArray array];
        if (latest1.count>0)
        {
            for (int i=0;i<latest1.count;i++)
            {
                SecondWDWD*sec=[SecondWDWD userWithDictionary:latest1[i]];
                [_latest1 addObject:sec];
                NSLog(@"_latest1.count  %lu",(unsigned long)_latest1.count);
            }
        }
        if (latest7.count>0)
        {
            for (int i=0;i<latest7.count; i++)
            {
                SecondWDWD*sec=[SecondWDWD userWithDictionary:latest7[i]];
                [_latest7 addObject:sec];
                 NSLog(@"_latest1.count  %lu",(unsigned long)_latest7.count);
            }
        }
        if (previous.count>0)
        {
            for (int i=0; i<previous.count; i++)
            {
                 SecondWDWD*sec=[SecondWDWD userWithDictionary:previous[i]];
                [_previous addObject:sec];
                 NSLog(@"_latest1.count  %lu",(unsigned long)_previous.count);
            }
        }
        
        
        
    }
    return self;
}

@end
